home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Developer Toolbox 6.1
/
SGI Developer Toolbox 6.1 - Disc 4.iso
/
src
/
swtools
/
trubasic
/
rolldemos
/
demos
/
interact
/
tbedit.tru
< prev
next >
Wrap
Text File
|
1994-08-02
|
4KB
|
142 lines
! ****************************************************************************
! file: tbedit
!
! function: adjusts the rgb color mix of a True BASIC color using
! the mouse to adjust slider bars that visually represent the mix.
! (similar to cedit on the Silicon Graphics)
!
! NOTE: this program is written using singlebuffer mode.
! to avoid the slight flicker when the image is redrawn, use doublebuffer mode.
!
! ****************************************************************************
! draw the image with slider bars, rgb values, etc.
! respond to mouse events by adjusting the slider bar, the intensity, and
! resdisplaying the actual color. handle redraw events.
! the window scale is the default 0 to 1
when error in
call tw_wset_title(0,"tbedit") ! window title
call winfo("set resize","1") ! window to resized
set text justify "center","base" ! center text
option nolet ! make the LET optional on assignments
clear
set mode "dynamic" ! use read-write colors for X
fore$="black"
back$="white"
set back back$
clear
zero,yr,yg,yb=.17 ! y value for slider bar boxes
clr=21 ! color we are adjusting
set color mix (clr) 0,0,0
rstart=.1 ! x values for slider boxes
rend=.2
gstart=.3
gend=.4
bstart=.5
bend=.6
bot=.15 ! top and bottom of slider boxes
top=.95
slidetop=.92
slidebot=.17
down=1
call draw_image ! draw the image
do
if key input then stop
get mouse x,y,state
if refresh(1)=1 then call draw_image ! handle refresh events
if state=down then ! handle mouse events
if y<slidebot then y=slidebot
if y>slidetop then y=slidetop
if y<>yr and x>rstart and x<rend then ! adjust red value
call clear_red
yr=y
r=(y-slidebot)/(slidetop-slidebot)
set color mix (clr) r,g,b
call update_red
end if
if y<>yg and x>gstart and x<gend then ! adjust green value
call clear_green
yg=y
g=(y-slidebot)/(slidetop-slidebot)
set color mix (clr) r,g,b
call update_green
end if
if y<>yb and x>bstart and x<bend then ! adjust blue value
call clear_blue
yb=y
b=(y-slidebot)/(slidetop-slidebot)
set color mix (clr) r,g,b
call update_blue
end if
end if
loop
use
! an error occurred, print message and stop
set mode "text"
print extext$,extype,exline$
stop
end when
! update the box that displays the current color
sub update_box
set color clr
box area .72,.92,.17,.92
set color fore$
box lines .72,.92,.17,.92
end sub
! draw the image in the window (slider bars, rgb values, etc)
sub draw_image
clear
call update_box
call update_red
call update_green
call update_blue
box lines rstart,rend,bot,top
box lines gstart,gend,bot,top
box lines bstart,bend,bot,top
plot text, at .82,.05: str$(clr)
end sub
sub clear_blue
set color back$
box area bstart+.02,bend-.02,yb,yb+.02
box area .4,.65,.05,.12
end sub
sub clear_green
set color back$
box area gstart+.02,gend-.02,yg,yg+.02
box area .2,.45,.05,.12
end sub
sub clear_red
set color back$
box area rstart+.02,rend-.02,yr,yr+.02
box area 0,.25,.05,.12
end sub
sub update_blue
set color "blue"
box area bstart+.02,bend-.02,yb,yb+.02
set color fore$
plot text, at .54,.05: str$(int(b*255))
end sub
sub update_green
set color "green"
box area gstart+.02,gend-.02,yg,yg+.02
set color fore$
plot text, at .34,.05: str$(int(g*255))
end sub
sub update_red
set color "red"
box area rstart+.02,rend-.02,yr,yr+.02
set color fore$
plot text, at .15,.05: str$(int(r*255))
end sub
end